#coding=utf-8
__author__ = 'liubin'

from sqlalchemy.orm import joinedload
from tornado_json.requesthandlers import APIHandler
from project.tools import HandlerMixin
from project.models import User

class BaseHandler(HandlerMixin, APIHandler):
    """
    基本的handler
    """
    def get_user(self):
        """
        获取当前用户
        :return:
        """
        userId = self.get_current_user()
        user = self.db_conn.query(User).options(joinedload(User.role, innerjoin=True))\
         .filter(User.userId == userId).first()
        return user